package com.kg.fiber.common;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.log4j.Log4j;

@Log4j
public class TimedDoubleBuffer extends DoubleBuffer {
	
	public static final Pool<TimedDoubleBuffer> pool = new Pool<TimedDoubleBuffer>() {

		@Override
		protected TimedDoubleBuffer create() {
			try {
				TimedDoubleBuffer data = new TimedDoubleBuffer();
				log.info("TimedDoubleBuffer created, count = " + this.getTotal());
				return data;
			} catch(Throwable e) {
				log.fatal("create TimedDoubleBuffer failed.", e);
				return null;
			}
		}

		@Override
		protected void beforeGet(TimedDoubleBuffer t) {
			t.clear();
			//log.info("Get buffer");
		}

		@Override
		protected void afterBack(TimedDoubleBuffer t) {
			//log.info("Back buffer, queue count is " + (this.getUsed() + 1));
			//super.afterBack(t);
		}
		
	};
	
	@Getter @Setter
	private long timestamp;
		
	private TimedDoubleBuffer(){
		super(16 * 1024);
	}
	
	
}
